package com.jy.rhin.facade.infra.controller.notification;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jy.framework.base.entity.Result;
import com.jy.rhin.application.infra.NotificationApplicationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author WeiQ
 * @date 2022/6/28 10:31
 */
@RestController
@RequestMapping("/notification/test")
@Api(hidden = true)
public class InfraTestController {

    @Resource
    NotificationApplicationService notificationApplicationService;

    @PostMapping("/publish")
    @ApiOperation(value = "publish", hidden = true)
    public Result<String> publish(@RequestBody JSONObject message) {
        Long id = notificationApplicationService.receive(JSON.toJSONString(message.getJSONObject("data")), message.getString("msgId"), message.getString("sender"), new Date());
        return Result.success(String.valueOf(id));
    }

}
